﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CompressDataSet;
using System.IO;
using System.IO.Compression;
using System.Runtime.Serialization.Formatters.Binary;
using System.Diagnostics;


namespace LearnDrive
{
    public partial class testUpdata : Form
    {
        WebReference2.Heart s = new WebReference2.Heart();
        public testUpdata()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            //Stopwatch sw = new Stopwatch();
            //sw.Start();
            //byte[] zipBuffer = s.GetUpdata("fname,fneirong,sign,gengxinshijian","tbl_shengyintp"," where fname='1407041.jpg' ");
            //byte[] buffer = DeCompress(zipBuffer);
            //BinaryFormatter bf = new BinaryFormatter();
            //DataSetSurrogate dss = bf.Deserialize(new MemoryStream(buffer)) as DataSetSurrogate;
            //DataSet ds = dss.ConvertToDataSet();


            Stopwatch sw = new Stopwatch();
            sw.Start();
            byte[] buffer = s.GetUpdata("fname,fneirong,sign,gengxinshijian", "tbl_shengyintp", " where fname='1407041.jpg' ");
            BinaryFormatter bf = new BinaryFormatter();
            DataSetSurrogate dss = bf.Deserialize(new MemoryStream(buffer)) as DataSetSurrogate;
            DataSet ds = dss.ConvertToDataSet();
          
            sw.Stop();

            //Label4.Text = string.Format("耗时：{1}毫秒；数据大小：{0}", zipBuffer.Length.ToString(), sw.ElapsedMilliseconds.ToString());  
        }


        ////解压压缩后的字节数组  
        //public byte[] DeCompress(byte[] data)
        //{
        //    MemoryStream ms = new MemoryStream();
        //    Stream zipStream = new GZipStream(ms, CompressionMode.Decompress, true);
        //    zipStream.Write(data, 0, data.Length);
        //    zipStream.Close();
        //    ms.Position = 0;
        //    byte[] buffer = new byte[ms.Length];
        //    ms.Read(buffer, 0, int.Parse(ms.Length.ToString()));
        //    return buffer;
        //}   
    }
}
